home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol2 / Archives / Plain / jf93.lha / ASCII / Packets / Packets.txt < prev   
Encoding:
Text File  |  1993-03-01  |  53.9 KB  |  1,298 lines

  1. (c)  Copyright 1990-1993 Commodore-Amiga, Inc.   All rights reserved.
  2. The information contained herein is subject to change without notice,
  3. and is provided "as is" without warranty of any kind, either expressed
  4. or implied.  The entire risk as to the use of this information is
  5. assumed by the user.
  6.  
  7.  
  8. AmigaDOS Packet Interface Specification
  9.  
  10. by John Toebes
  11.  
  12.  
  13. AmigaDOS communicates with file systems and other DOS handlers by
  14. sending and receiving packets.  Opening and closing file handles
  15. (including console file handles), creating directories, and renaming
  16. disks all require DOS to tell a handler to perform these actions
  17. through sending a packet.  The particular action a handler performs
  18. depends on the type of packet it receives.
  19.  
  20. This article documents the standard AmigaDOS packet types.  For
  21. information on how to use packets to communicate with handlers see
  22. the AmigaDOS Manual.
  23.  
  24. Packets sent to a file system or handler can be divided into several
  25. basic categories:
  26.  
  27.     o   Basic Input/Output
  28.  
  29. These actions deal with tranferring data to and from objects
  30. controlled by the handler.
  31.  
  32.     o   File/Directory Manipulation/Information
  33.  
  34. These actions are used to gain access to and manipulate the high
  35. level structures of the file system.
  36.  
  37.     o   Volume Manipulation/Information
  38.  
  39. These actions allow access to the specific volume controlled by the
  40. file system.
  41.  
  42.     o   Handler Maintenance and Control
  43.  
  44. These allow control over the handler/file system itself, independent
  45. of the actual volume or structure underneath.
  46.  
  47.     o   Handler Internal
  48.  
  49. These actions are never sent to the handler directly.  Instead they
  50. are generally responses to IO requests made by the handler.  The
  51. handler makes these responses look like packets in order to simplify
  52. processing.
  53.  
  54.     o   Obsolete Packets
  55.  
  56. These packets are no longer valid for use by handlers and file
  57. systems.
  58.  
  59.     o   Console Only Packets
  60.  
  61. These packets are specific to console handlers.  File Systems can
  62. ignore these packets.
  63.  
  64.  
  65. Much of this information can be extracted from Developer Conference
  66. notes, The AmigaDOS Manual, and various Fred Fish disks.  However,
  67. because there is no single complete reference to these packet types,
  68. a consolidated view of all the packets is presented here.  Several
  69. structures are referenced here which can be found by looking at the
  70. include files <dos/dos.h> and <dos/dosextens.h>.  (If you are using
  71. the 1.3 version of the include files, these are in the libraries
  72. directory instead of the dos directory).  Before attempting to work
  73. with a file handler you should first become familiar with these files.
  74.  
  75. Each packet type documented in this article is listed with its action
  76. name, its corresponding number, any AmigaDOS routines which uses this
  77. packet, and the list of  parameters that the packets uses.  The C
  78. variable types for the packet parameters are one of the following
  79. types:
  80.  
  81.  
  82. BPTR    This is BCPL pointer (the address of the given object shifted
  83.         right by 2).  Note: this means that the object must be
  84.         aligned on a longword boundary.
  85.  
  86.  
  87. LOCK    This is a BPTR to a FileLock structure returned by a previous
  88.         ACTION_LOCATE_OBJECT.  A lock of 0 is legal, indicating the
  89.         root of the volume for the handler.
  90.  
  91.  
  92. BSTR    This is a BPTR to a string where the first byte indicates the
  93.         number of characters in the string.  This length byte is
  94.         unsigned but because it is stored in a byte, the strings are
  95.         limited to 255 characters in length.
  96.  
  97.  
  98. BOOL    A 32-bit boolean value either containing DOSTRUE (-1) or
  99.         DOSFALSE (0).  Note: equality comparisons with DOSTRUE should
  100.         be avoided.
  101.  
  102.  
  103. CODE    A 32 bit error code as defined in the dos/dos.h include file.
  104.         Handlers should not return error codes besides those defined
  105.         in dos/dos.h.
  106.  
  107.  
  108. ARG1    The FileHandle->fh_Arg1 field.
  109.  
  110.  
  111. LONG    A 32 bit integer value.
  112.  
  113.  
  114. Basic Input/Output
  115.  
  116. The Basic Input/Output actions are supported by both handlers and
  117. file systems.  In this way, the application can get a stream level
  118. access to both devices and files.  One difference that arises between
  119. the two is that a handler will not necessarily support an ACTION_SEEK
  120. while it is generally expected for a file system to do so.
  121.  
  122. These actions work based on a FileHandle which is filled in by one of
  123. the three forms of opens:
  124.  
  125. ACTION_FINDINPUT         1005    Open(..., MODE_OLDFILE)
  126. ACTION_FINDOUTPUT        1006    Open(..., MODE_NEWFILE)
  127. ACTION_FINDUPDATE        1004    Open(..., MODE_READWRITE)
  128. ARG1:   BPTR    FileHandle to fill in
  129. ARG2:   LOCK    Lock on directory that ARG3 is relative to
  130. ARG3:   BSTR    Name of file to be opened (relative to ARG1)
  131.  
  132. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  133. RES2:   CODE    Failure code if RES1 is DOSFALSE
  134.  
  135. All three actions use the lock (ARG2) as a base directory location
  136. from which to open the file.  If this lock is NULL, then the file
  137. name (ARG3) is relative to the root of the current volume.  Because
  138. of this, file names are not limited to a single file name but instead
  139. can include a volume name (followed by a colon) and multiple slashes
  140. allowing the file system to fully resolve the name.  This eliminates
  141. the need for AmigaDOS or the application to parse names before
  142. sending them to the file system.  Note that the lock in ARG2 must be
  143. associated with the file system in question.  It is illegal to use a
  144. lock from another file system.
  145.  
  146. The calling program owns the file handle (ARG1).  The program must
  147. initialize the file handle before trying to open anything  (in the
  148. case of a call to Open(), AmigaDOS allocates the file handle
  149. automatically and then frees it in Close() ).  All fields must be
  150. zero except the fh_Pos and fh_End fields which should be set to -1.
  151. The Open() function fills in the fh_Type field with a pointer to the
  152. MsgPort of the handler process.  Lastly, the handler must initialize
  153. fh_Arg1 with something that allows the handler to uniquely locate the
  154. object being opened (normally a file).  This value is implementation
  155. specific.  This field is passed to the READ/WRITE/SEEK/ END/TRUNCATE
  156. operations and not the file handle itself.
  157.  
  158. FINDINPUT and FINDUPDATE are similar in that they only succeed if the
  159. file already exists.  FINDINPUT will open with a shared lock while
  160. FINDUPDATE will open it with a shared lock but if the file doesn't
  161. exist, FINDUPDATE will create the file.  FINDOUTPUT will always open
  162. the file (deleting any existing one) with an exclusive lock.
  163.  
  164.  
  165. ACTION_READ              'R'     Read(...)
  166. ARG1:   ARG1    fh_Arg1 field of the opened FileHandle
  167. ARG2:   APTR    Buffer to put data into
  168. ARG3:   LONG    Number of bytes to read
  169.  
  170. RES1:   LONG    Number of bytes read.
  171.        0 indicates EOF.
  172.       -1 indicates ERROR
  173. RES2:   CODE    Failure code if RES1 is -1
  174.  
  175. This action extracts data from the file  (or input channel) at the
  176. current position.  If fewer bytes remain in the file than requested,
  177. only those bytes remaining will be returned with the number of bytes
  178. stored in RES1.  The handler indicates an error is indicated by
  179. placing a -1 in RES1 and the error code in RES2.  If the read fails,
  180. the current file position remains unchanged.  Note that a handler may
  181. return a smaller number of bytes than requested, even if not at the
  182. end of a file.  This happens with interactive type file handles which
  183. may return one line at a time as the user hits return, for example
  184. the console handler, CON:.
  185.  
  186.  
  187. ACTION_WRITE             'W'     Write(...)
  188. ARG1:   ARG1    fh_Arg1 field of the opened file handle
  189. ARG2:   APTR    Buffer to write to the file handle
  190. ARG3:   LONG    Number of bytes to write
  191.  
  192. RES1:   LONG    Number of bytes written.
  193. RES2:   CODE    Failure code if RES1 not the same as ARG3
  194.  
  195. This action copies data into the file (or output channel) at the
  196. current position.  The file is automatically extended if the write
  197. passes the end of the file.  The handler indicates failure by
  198. returning a byte count in RES1 that differs from the number of bytes
  199. requested in ARG3.  In the case of a failure, the handler does not
  200. update the current file position (although the file may have been
  201. extended and some data overwritten) so that an application can safely
  202. retry the operation.
  203.  
  204.  
  205. ACTION_SEEK              1008    Seek(...)
  206. ARG1:   ARG1    fh_Arg1 field of the opened FileHandle
  207. ARG2:   LONG    New Position
  208. ARG3:   LONG    Mode:   OFFSET_BEGINNING,OFFSET_END, or  OFFSET_CURRENT
  209.  
  210. RES1:   LONG    Old Position.   -1 indicates an error
  211. RES2:   CODE    Failure code if RES1 = -1
  212.  
  213. This packet sets the current file position.  The new position (ARG2)
  214. is relative to either the beginning of the file (OFFSET_BEGINNING),
  215. the end of the file (OFFSET_END), or the current file position
  216. (OFFSET_CURRENT), depending on the mode set in ARG3.  Note that ARG2
  217. can be negative.  The handler returns the previous file position in
  218. RES1.  Any attempt to seek past the end of the file will result in an
  219. error and will leave the current file position in an unknown location.
  220.  
  221.  
  222. ACTION_END               1007    Close(...)
  223. ARG1:   ARG1    fh_Arg1 field of the opened FileHandle
  224.  
  225. RES1:   LONG    DOSTRUE
  226.  
  227. This packet closes an open file handle.  This function generally
  228. returns a DOSTRUE as there is little the application can do to
  229. recover from a file closing failure.  If an error is returned under
  230. 2.0, DOS will not deallocate the file handle.  Under 1.3, it does not
  231. check the result.
  232.  
  233.  
  234. ACTION_LOCK_RECORD       2008    LockRecord(fh,pos,len,mod,tim)
  235. ARG1:   BPTR    FileHandle to lock record in
  236. ARG2:   LONG    Start position (in bytes) of record in the file
  237. ARG3:   LONG    Length (in bytes) of record to be locked
  238. ARG4:   LONG    Mode
  239.                  0 = Exclusive
  240.                  1 = Immediate Exclusive (timeout is ignored)
  241.                  2 = Shared
  242.                  3 = Immediate Shared (timeout is ignored)
  243. ARG5:   LONG    Timeout period in AmigaDOS ticks (0 is legal)
  244.  
  245. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  246. RES2:   CODE    Failure code if RES1 is DOSFALSE
  247.  
  248. This function locks an area of a file in either a sharable
  249. (indicating read-only) or exclusive (indicating read/write) mode.
  250. Several sharable record locks from different file handles can exist
  251. simultaneously on a particular file area but only one file handle can
  252. have exclusive record locks on a particular area at a time.  The
  253. ``exclusivity'' of an exclusive file lock only applies to record
  254. locks from other file handles, not to record locks within the file
  255. handle.  One file handle can have any number of overlapping exclusive
  256. record locks.  In the event of overlapping lock ranges, the entire
  257. range must be lockable before the request can succeed.  The timeout
  258. period (ARG5) is the number of AmigaDOS ticks (1/50 second) to wait
  259. for success before failing the operation.
  260.  
  261.  
  262. ACTION_FREE_RECORD       2009    UnLockRecord(file,pos,len)
  263. ARG1:   BPTR    FileHandle to unlock record in
  264. ARG2:   LONG    Start position (in bytes) of record in the file
  265. ARG3:   LONG    Length of record (in bytes) to be unlocked
  266.  
  267. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  268. RES2:   CODE    Failure code if RES1 is DOSFALSE
  269.  
  270. This function unlocks any previous record lock.  If the given range
  271. does not represent one that is currently locked in the file,
  272. ACTION_FREE_RECORD returns an error.  In the event of multiple locks
  273. on a given area, only one lock is freed.
  274.  
  275.  
  276. ACTION_SET_FILE_SIZE     1022    SetFileSize(file,off,mode)
  277. ARG1:   BPTR    FileHandle of opened file to modify
  278. ARG2:   LONG    New end of file location based on mode
  279. ARG3:   LONG    Mode.  One of OFFSET_CURRENT, OFFSET_BEGIN, or OFFSET_END
  280.  
  281. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  282. RES2:   CODE    Failure code if RES1 is DOSFALSE
  283.  
  284. This function is used to change the physical size of an opened file.
  285. ARG2, the new end-of-file position, is relative to either the current
  286. file position (OFFSET_CURRENT), the beginning of the file
  287. (OFFSET_BEGIN), or the end of the file (OFFSET_END), depending on the
  288. mode set in ARG3.  The current file position will not change unless
  289. the current file position is past the new end-of-file position.  In
  290. this case, the new file position will move to the new end of the
  291. file.  If there are other open file handles on this file,
  292. ACTION_SET_FILE_SIZE sets the end-of-file for these alternate file
  293. handles to either their respective current file position or to the
  294. new end-of-file position of the file handle in ARG1, whichever makes
  295. the file appear longer.
  296.  
  297.  
  298. Directory/File Manipulation/Information
  299.  
  300. The directory/file actions permits an application to make queries
  301. about and modifications to handler objects. These packets perform
  302. functions such as creating subdirectories, resolving links, and
  303. filling in FileInfoBlock structures for specific files.
  304.  
  305.  
  306. ACTION_LOCATE_OBJECT     8       Lock(...)
  307. ARG1:   LOCK    Lock on directory to which ARG2 is relative
  308. ARG2:   BSTR    Name (possibly with a path) of object to lock
  309. ARG3:   LONG    Mode:   ACCESS_READ/SHARED_LOCK, ACCESS_WRITE/EXCLUSIVE_LOCK
  310.  
  311. RES1:   LOCK    Lock on requested object or 0 to indicate failure
  312. RES2:   CODE    Failure code if RES1 = 0
  313.  
  314. The AmigaDOS function Lock() uses this action to create its locks.
  315. Given a name for the object, which may include a path, (ARG2)  and a
  316. lock on a directory from which to look for the name (and path),
  317. ACTION_LOCATE_OBJECT will locate the object within the file system
  318. and create a FileLock structure associated with the object.  If  the
  319. directory lock in ARG1 is NULL, the name is relative to the root of
  320. the file handler's volume (a.k.a. ``:'').  The memory for the
  321. FileLock structure returned in RES1 is maintained by the handler and
  322. freed by an ACTION_FREE_LOCK.  Although it's not a requirement, if an
  323. handler expects to support the pre-1.3 Format command, it must accept
  324. any illegal mode as ACCESS_READ.
  325.  
  326. A handler can create an exclusive lock only if there are no other
  327. outstanding locks on the given object. Once created, an exclusive
  328. lock prevents any other locks from being created for that object.  In
  329. general, a handler uses the FileLock->fl_Key field to uniquely
  330. identify an object.  Note that some applications rely on this
  331. (although a handler is not required to implement this packet).
  332.  
  333. The fl_Volume field of the returned FileLock structure should point
  334. to the DOS device list's volume entry for the volume on which the
  335. lock exists.  In addition, there are several diagnostic programs that
  336. expect all locks for a volume to be chained together off the
  337. dl_LockList field in the volume entry.  Note that relying on this
  338. chaining is not safe, and can cause serious problems including a
  339. system crash.  No application should use it.
  340.  
  341.  
  342. ACTION_COPY_DIR          19      DupLock(...)
  343. ARG1:   LOCK    Lock to duplicate
  344.  
  345. RES1:   LOCK    Duplicated Lock or 0 to indicate failure
  346. RES2:   CODE    Failure code if RES1 = 0
  347.  
  348. This action's name is misleading as it does not manipulate
  349. directories.  Instead, it creates a copy of a shared lock.  The copy
  350. is subsequently freed with an ACTION_FREE_LOCK.  Note that it is
  351. valid to pass a NULL lock.  Currently, the DupLock() call always
  352. returns 0 if passed a 0, although a handler is not required to return
  353. a 0.
  354.  
  355.  
  356. ACTION_FREE_LOCK         15      UnLock(...)
  357. ARG1:   LOCK    Lock to free
  358.  
  359. RES1:   BOOL    TRUE
  360.  
  361. This action frees the lock passed to it.  The AmigaDOS function
  362. Unlock() uses this packet.  If passed a NULL lock, the handler should
  363. return success.
  364.  
  365.  
  366. ACTION_EXAMINE_OBJECT    23      Examine(...)
  367. ARG1:   LOCK    Lock of object to examine
  368. ARG2:   BPTR    FileInfoBlock to fill in
  369.  
  370. RES1:   BOOL    Success/failure (DOSTRUE/DOSFALSE)
  371. RES2:   CODE    Failure code if RES1 = DOSFALSE
  372.  
  373. This action fills in the FileInfoBlock with information about the
  374. locked object.  The Examine() function uses this packet.  This packet
  375. is actually used for two different types of operations.  It is called
  376. to obtain information about a given object while in other cases, it
  377. is called to prepare for a sequence of EXAMINE_NEXT operations in
  378. order to traverse a directory.
  379.  
  380. This seemingly simple operation is not without its quirks.  One in
  381. particular is the FileInfoBlock->fib_Comment field.  This field used
  382. to be 116 bytes long, but was changed to 80 bytes in release 1.2.
  383. The extra 36 bytes lie in the fib_Reserved field.  Another quirk of
  384. this packet is that both the fib_EntryType and the fib_DirEntryType
  385. fields must be set to the same value, as some programs look at one
  386. field while other programs look at the other.
  387.  
  388. File systems should use the same values for fib_DirEntryType as the
  389. ROM file system and ram-handler do.  These are as follows:
  390.  
  391. ST_ROOT          1
  392. ST_USERDIR       2
  393. ST_SOFTLINK      3 NOTE: this Shows up as a directory unless checked for explicitly
  394. ST_LINKDIR       4
  395. ST_FILE         -3
  396. ST_LINKFILE     -4
  397.  
  398. Also note that for directories, handlers must use numbers greater
  399. than 0, since some programs test to see if fib_DirEntryType is
  400. greater than zero, ignoring the case where fib_DirEntryType equals 0.
  401. Handlers should avoid using 0 because it is not interpreted
  402. consistently.
  403.  
  404.  
  405. ACTION_EXAMINE_NEXT      24      ExNext(...)
  406. ARG1:   LOCK    Lock on directory being examined
  407. ARG2:   BPTR    BPTR FileInfoBlock
  408.  
  409. RES1:   BOOL    Success/failure (DOSTRUE/DOSFALSE)
  410. RES2:   CODE    Failure code if RES1 = DOSFALSE
  411.  
  412. The ExNext() function uses this packet to obtain information on all
  413. the objects in a directory.   ACTION_EXAMINE fills in a FileInfoBlock
  414. structure describing the first file or directory stored in the
  415. directory referred to in the lock in ARG1.  ACTION_EXAMINE_NEXT is
  416. used to find out about the rest of the files and directories stored
  417. in the ARG1 directory.  ARG2 contains a pointer to a valid
  418. FileInfoBlock field that was filled in by either an ACTION_EXAMINE or
  419. a previous ACTION_EXAMINE_NEXT call.  It uses this structure to find
  420. the next entry in the directory.  This packets writes over the old
  421. FileInfoBlock with information on the next file or directory in the
  422. ARG2 directory.  ACTION_EXAMINE_NEXT returns a failure code of
  423. ERROR_NO_MORE_ENTRIES when there are no more files or directories
  424. left to be examined.  Unfortunately, like ACTION_EXAMINE, this packet
  425. has its own peculiarities.  Among the quirks that ACTION_EXAMINE_NEXT
  426. must account for are:
  427.  
  428. · The situation where an application calls ACTION_EXAMINE_NEXT one or
  429. more times and then stops invoking it before encountering the end of
  430. the directory.
  431.  
  432. · The situation where a FileInfoBlock passed to ACTION_EXAMINE_NEXT
  433. is not the same as the one passed to ACTION_EXAMINE or even the
  434. previous EXAMINE_NEXT operation.  Instead, it is a copy of the
  435. FileInfoBlock with only the fib_DiskKey and the first 30 bytes of the
  436. fib_FileName fields copied over.  This is now considered to be
  437. illegal and will not work in the future.  Any new code should not be
  438. written in this manner.
  439.  
  440. · Because a handler can receive other packet types between
  441. ACTION_EXAMINE_NEXT operations, the ACTION_EXAMINE_NEXT function must
  442. handle any special cases that may result.
  443.  
  444. · The LOCK passed to ACTION_EXAMINE_NEXT is not always the same lock
  445. used in previous operations.  It is however a lock on the same object.
  446.  
  447. Because of these problems, ACTION_EXAMINE_NEXT is probably the
  448. trickiest action to write in any handler.  Failure to handle any of
  449. the above cases can be quite disastrous.
  450.  
  451.  
  452. ACTION_CREATE_DIR        22      CreateDir(...)
  453. ARG1:   LOCK    Lock to which ARG2 is relative
  454. ARG2:   BSTR    Name of new directory  (relative to ARG1)
  455.  
  456. RES1:   LOCK    Lock on new directory
  457. RES2:   CODE    Failure code if RES1 = DOSFALSE
  458.  
  459. ACTION_DELETE_OBJECT     16      DeleteFile(...)
  460. ARG1:   LOCK    Lock to which ARG2 is relative
  461. ARG2:   BSTR    Name of object to delete (relative to ARG1)
  462.  
  463. RES1:   BOOL    Success/failure (DOSTRUE/DOSFALSE)
  464. RES2:   CODE    Failure code if RES1 = DOSFALSE
  465.  
  466. ACTION_RENAME_OBJECT     17      Rename(...)
  467. ARG1:   LOCK    Lock to which ARG2 is relative
  468. ARG2:   BSTR    Name of object to rename (relative to ARG1)
  469. ARG3:   LOCK    Lock associated with target directory
  470. ARG4:   BSTR    Requested new name for the object
  471.  
  472. RES1:   BOOL    Success/failure (DOSTRUE/DOSFALSE)
  473. RES2:   CODE    Failure code if RES1 = DOSFALSE
  474.  
  475. These three actions perform most of the work behind the AmigaDOS
  476. commands MakeDir, Delete, and Rename  (for single files).  These
  477. packets take as their parameters a lock describing where the file is
  478. and a name relative to that lock.  It is the responsibility of the
  479. file system to ensure that the operation is not going to cause
  480. adverse effects.  In particular, the RENAME_OBJECT action allows
  481. moving files across directory bounds and as such must ensure that it
  482. doesn't create hidden directory loops by renaming a directory into a
  483. child of itself.
  484.  
  485. For Directory objects, the DELETE_OBJECT action must ensure that the
  486. directory is empty before allowing the operation.
  487.  
  488.  
  489. ACTION_PARENT            29      Parent(...)
  490. ARG1:   LOCK    Lock on object to get the parent of
  491.  
  492. RES1:   LOCK    Parent Lock
  493. RES2:   CODE    Failure code if RES1 = 0
  494.  
  495. This action receives a lock on an object and creates a shared lock on
  496. the object's parent.  If the original object has no parent, then a
  497. lock of 0 is returned.  Note that this operation is typically used in
  498. the process of constructing the absolute path name of a given object.
  499.  
  500.  
  501. ACTION_SET_PROTECT       21      SetProtection(...)
  502. ARG1:   Unused
  503. ARG2:   LOCK    Lock to which ARG3 is relative
  504. ARG3:   BSTR    Name of object (relative to ARG2)
  505. ARG4:   LONG    Mask of new protection bits
  506.  
  507. RES1:   BOOL    Success/failure (DOSTRUE/DOSFALSE)
  508. RES2:   CODE    Failure code if RES1 = DOSFALSE
  509.  
  510. This action allows an application to modify the protection bits of an
  511. object.  The 4 lowest order bits (RWED) are a bit peculiar.  If their
  512. respective bit is set, that operation is not allowed (i.e. if a
  513. file's delete bit is set the file is not deleteable).  By default,
  514. files are created with the RWED bits set and all others cleared.
  515. Additionally, any action which modifies a file is required to clear
  516. the A (archive) bit.  See the dos/dos.h include file for the
  517. definitions of the bit fields.
  518.  
  519.  
  520. ACTION_SET_COMMENT       28      SetComment(...)
  521. ARG1:   Unused
  522. ARG2:   LOCK    Lock to which ARG3 is relative
  523. ARG3:   BSTR    Name of object (relative to ARG2)
  524. ARG4:   BSTR    New Comment string
  525.  
  526. RES1:   BOOL    Success/failure (DOSTRUE/DOSFALSE)
  527. RES2:   CODE    Failure code if RES1 = DOSFALSE
  528.  
  529. This action allows an application to set the comment string of an
  530. object.  If the object does not exist then DOSFALSE will be returned
  531. in RES1 with the failure code in RES2.  The comment string is limited
  532. to 79 characters.
  533.  
  534.  
  535. ACTION_SET_DATE          34      SetFileDate(...) in 2.0
  536. ARG1:   Unused
  537. ARG2:   LOCK    Lock to which ARG3 is relative
  538. ARG3:   BSTR    Name of Object (relative to ARG2)
  539. ARG4:   CPTR    DateStamp
  540.  
  541. RES1:   BOOL    Success/failure (DOSTRUE/DOSFALSE)
  542. RES2:   CODE    Failure code if RES1 = DOSFALSE
  543.  
  544. This action allows an application to set an object's creation date.
  545.  
  546.  
  547. ACTION_FH_FROM_LOCK      1026    OpenFromLock(lock)
  548. ARG1:   BPTR    BPTR to file handle to fill in
  549. ARG2:   LOCK    Lock of file to open
  550.  
  551. RES1:   BOOL    Success/failure (DOSTRUE/DOSFALSE)
  552. RES2:   CODE    Failure code if RES1 = NULL
  553.  
  554. This action open a file from a given lock.  If this action is
  555. successful, the file system will essentially steal the lock so a
  556. program should not use it anymore.  If ACTION_FH_FROM_LOCK fails, the
  557. lock is still usable by an application.
  558.  
  559.  
  560. ACTION_SAME_LOCK         40      SameLock(lock1,lock2)
  561. ARG1:   BPTR    Lock 1 to compare
  562. ARG2:   BPTR    Lock 2 to compare
  563.  
  564. RES1:   LONG    Result of comparison, one of
  565.     DOSTRUE           if locks are for the same object
  566.     DOSFALSE          if locks are on different objects
  567. RES2:   CODE    Failure code if RES1 is LOCK_DIFFERENT
  568.  
  569. This action compares the targets of two locks.  If they point to the
  570. same object, ACTION_SAME_LOCK should return LOCK_SAME.
  571.  
  572.  
  573. ACTION_MAKE_LINK         1021    MakeLink(name,targ,mode)
  574. ARG1:   BPTR    Lock on directory ARG2 is relative to
  575. ARG2:   BSTR    Name of the link to be created (relative to ARG1)
  576. ARG3:   BPTR    Lock on target object or name (for soft links).
  577. ARG4:   LONG    Mode of link, either LINK_SOFT or LINK_HARD
  578.  
  579. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  580. RES2:   CODE    Failure code if RES1 is DOSFALSE
  581.  
  582. This packet causes the file system to create a link to an already
  583. existing file or directory.  There are two kinds of links, hard links
  584. and soft links.  The basic difference between them is that a file
  585. system resolves a hard link itself, while the file system passes a
  586. string back to DOS telling it where to find a soft linked file or
  587. directory.   To the packet level programmer, there is essentially no
  588. difference between referencing a file by its original name or by its
  589. hard link name.  In the case of a hard link, ARG3 is a lock on the
  590. file or directory that the link is ``linked'' to, while in a soft
  591. link, ARG3 is a pointer (CPTR) to a C-style string.
  592.  
  593. In an over-simplified model of the ROM file system, when asked to
  594. locate a file, the system scans a disk looking for a file header with
  595. a specific (file) name.  That file header points to the actual file
  596. data somewhere on the disk.  With hard links, more than one file
  597. header can point to the same file data, so data can be referenced by
  598. more than one name.  When the user tries to delete a hard link to a
  599. file, the system first checks to see if there are any other hard
  600. links to the file.  If there are, only the hard link is deleted, the
  601. actual file data the hard link used to reference remains, so the
  602. existing hard links can still use it.  In the case where the original
  603. link (not a hard or soft link) to a file is deleted, the file system
  604. will make one of its hard links the new ``real'' link to the file.
  605. Hard links can exist on directories as well.  Because hard links
  606. ``link'' directly to the underlying media, hard links in one file
  607. system cannot reference objects in another file system.
  608.  
  609. Soft links are resolved through DOS calls.  When the file system
  610. scans a disk for a file or directory name and finds that the name is
  611. a soft link, it returns an error code (ERROR_IS_SOFT_LINK).  If this
  612. happens, the application must ask the file system to tell it what the
  613. link the link refers to by calling ACTION_READ_LINK.  Soft Links are
  614. stored on the media, but instead of pointing directly to data on the
  615. disk, a soft link contains a path to its object.  This path can be
  616. relative to the lock in ARG1, relative to the volume (where the
  617. string will be prepended by a colon ':'), or an absolute path.  An
  618. absolute path contains the name of another volume, so a soft link can
  619. reference files and directories on other disks.
  620.  
  621.  
  622. ACTION_READ_LINK         1024  ReadLink(port,lck,nam,buf,len)
  623. ARG1:   BPTR    Lock on directory that ARG2 is relative to
  624. ARG2:   CPTR    Path and name of link (relative to ARG1).
  625.                   NOTE: This is a C string not a BSTR
  626. ARG3:   APTR    Buffer for new path string
  627. ARG4:   LONG    Size of buffer in bytes
  628.  
  629. RES1:   LONG    Actual length of returned string, -2 if there isn't
  630.                   enough space in buffer,or -1 for other errors
  631. RES2:   CODE    Failure code
  632.  
  633. This action reads a link and returns a path name to the link's
  634. object.  The link's name (plus any necessary path) is passed as a
  635. CPTR (ARG2) which points to a C-style string, not a BSTR.
  636. ACTION_READ_LINK returns the path name in ARG3.  The length of the
  637. target string is returned in RES1 (or a -1 indicating an error).
  638.  
  639.  
  640. ACTION_CHANGE_MODE       1028    ChangeMode(type,obj,mode)
  641. ARG1:   LONG    Type of object to change - either CHANGE_FH
  642.                   or CHANGE_LOCK
  643. ARG2:   BPTR    object to be changed
  644. ARG3:   LONG    New mode for object - see ACTION_FINDINPUT,
  645.                   and ACTION_LOCATE_OBJECT
  646.  
  647. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  648. RES2:   CODE    Failure code if RES1 is DOSFALSE
  649.  
  650. This action requests that the handler change the mode of the given
  651. file handle or lock to the mode in ARG3.  This request should fail if
  652. the handler can't change the mode as requested  (for example an
  653. exclusive request for an object that has multiple users).
  654.  
  655.  
  656. ACTION_COPY_DIR_FH       1030    DupLockFromFH(fh)
  657. ARG1:   LONG    fh_Arg1 of file handle
  658.  
  659. RES1:   BPTR    Lock associated with file handle or NULL
  660. RES2:   CODE    Failure code if RES1 = NULL
  661.  
  662. This action requests that the handler return a lock associated with
  663. the currently opened file handle.  The request may fail for any
  664. restriction imposed by the file system (for example when the file
  665. handle is not opened in a shared mode).  The file handle is still
  666. usable after this call, unlike the lock in ACTION_FH_FROM_LOCK.
  667.  
  668.  
  669. ACTION_PARENT_FH         1031    ParentOfFH(fh)
  670. ARG1:   LONG    fh_Arg1 of File handle to get parent of
  671.  
  672. RES1:   BPTR    Lock on parent of a file handle
  673. RES2:   CODE    Failure code if RES1 = NULL
  674.  
  675. This action obtains a lock on the parent directory (or root of the
  676. volume if at the top level) for a currently opened file handle.  The
  677. lock is returned as a shared lock and must be freed.  Note that
  678. unlike ACTION_COPY_DIR_FH, the mode of the file handle is
  679. unimportant.   For an open file, ACTION_PARENT_FH should return a
  680. lock under all circumstances.
  681.  
  682.  
  683. ACTION_EXAMINE_ALL       1033    ExAll(lock,buff,size,type,ctl)
  684. ARG1:   BPTR    Lock on directory to examine
  685. ARG2:   APTR    Buffer to store results
  686. ARG3:   LONG    Length (in bytes) of buffer (ARG2)
  687. ARG4:   LONG    Type of request - one of the following:
  688.            ED_NAME Return only file names
  689.            ED_TYPE Return above plus file type
  690.            ED_SIZE Return above plus file size
  691.            ED_PROTECTION Return above plus file protection
  692.            ED_DATE Return above plus 3 longwords of date
  693.            ED_COMMENT Return above plus comment or NULL
  694. ARG5:   BPTR    Control structure to store state information.  The control
  695.                   structure must be allocated with AllocDosObject()!
  696.  
  697. RES1:   LONG    Continuation flag - DOSFALSE indicates termination
  698. RES2:   CODE    Failure code if RES1 is DOSFALSE
  699.  
  700. This action allows an application to obtain information on multiple
  701. directory entries.  It is particularly useful for applications that
  702. need to obtain information on a large number of files and directories.
  703.  
  704. This action fills the buffer (ARG2) with partial or whole ExAllData
  705. structures.  The size of the ExAllData structure depends on the type
  706. of request.  If the request type field (ARG4) is set to ED_NAME, only
  707. the ed_Name field is filled in.  Instead of copying the unused fields
  708. of the ExAllData structure into the buffer, ACTION_EXAMINE_ALL
  709. truncates the unused fields.  This effect is cumulative, so requests
  710. to fill in other fields in the ExAllData structure causes all fields
  711. that appear in the structure before the requested field will be
  712. filled in as well.  Like the ED_NAME case mentioned above, any field
  713. that appears after the requested field will be truncated (see the
  714. ExAllData structure below).  For example, if the request field is set
  715. to ED_COMMENT, ACTION_EXAMINE_ALL fills in all the fields of the
  716. ExAllData structure, because the ed_Comment field is last.  This is
  717. the only case where the packet returns entire ExAllData structures.
  718.  
  719. struct ExAllData {
  720.         struct ExAllData *ed_Next;
  721.         UBYTE  *ed_Name;
  722.         LONG    ed_Type;
  723.         ULONG   ed_Size;
  724.         ULONG   ed_Prot;
  725.         ULONG   ed_Days;
  726.         ULONG   ed_Mins;
  727.         ULONG   ed_Ticks;
  728.         UBYTE  *ed_Comment;     /* strings will be after last used field. Note: */
  729. };                              /* Bug in V37 FFS treats this as a BSTR.        */
  730.  
  731. Each ExAllData structure entry has an ead_Next field which points to
  732. the next ExAllData structure.  Using these links, a program can
  733. easily chain through the ExAllData structures without having to worry
  734. about how large the structure is.  Do not examine the fields beyond
  735. those requested as they certainly will not be initialized (and will
  736. probably overlay the next entry).
  737.  
  738. The most important part of this action is the ExAllControl structure.
  739. It must be allocated and freed through
  740. AllocDosObject()/FreeDosObject().  This allows the structure to grow
  741. if necessary with future revisions of the operating and file systems.
  742. Currently, ExAllControl contains four fields:
  743.  
  744.     Entries - This field is maintained by the file system and
  745.     indicates the actual number of entries present in the
  746.     buffer after the action is complete.  Note that a value of
  747.     zero is possible here as no entries may match the match
  748.     string.
  749.  
  750.     LastKey - This field must be initialized to 0 by the
  751.     calling application before using this packet for the first
  752.     time.  This field is maintained by the file system as a
  753.     state indicator of the current place in the list of entries
  754.     to be examined.  The file system may test this field to
  755.     determine if this is the first or a subsequent call to this
  756.     action.
  757.  
  758.     MatchString - This field points to a pattern matching
  759.     string parsed by ParsePattern() or ParsePatternNoCase().
  760.     The string controls which directory entries are returned.
  761.     If this field is NULL, then all entries are returned.
  762.     Otherwise, this string is used to pattern match the names
  763.     of all directory entries before putting them into the
  764.     buffer.  The default AmigaDOS pattern match routine is used
  765.     unless MatchFunc is not NULL (see below).  Note that it is
  766.     not acceptable for the application to change this field
  767.     between subsequent calls to this action for the same
  768.     directory.
  769.  
  770.     MatchFunc - This field contains a pointer to an alternate
  771.     pattern matching routine to validate entries.  If it is
  772.     NULL then the standard AmigaDOS wild card routines will be
  773.     used.  Otherwise, MatchFunc points to a hook function that
  774.     is called in the following manner:
  775.  
  776. BOOL = MatchFunc(hookptr, data,typeptr)
  777.                    A0      A1    A2
  778. hookptr    Pointer to hook being called
  779. data       Pointer to (partially) filled in ExAllData for item
  780.              being checked.
  781. typeptr    Pointer to longword indicating the type of the
  782.              ExAll request (ARG4).
  783.  
  784. This function is expected to return DOSTRUE if the entry is accepted
  785. and DOSFALSE if it is to be discarded.
  786.  
  787.  
  788. ACTION_EXAMINE_FH        1034    ExamineFH(fh,fib)
  789. ARG1:   BPTR    File handle on open file
  790. ARG2:   BPTR    FileInfoBlock to fill in
  791.  
  792. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  793. RES2:   CODE    Failure code if RES1 is DOSFALSE
  794.  
  795. This function examines a file handle and fills in the FileInfoBlock
  796. (found in ARG2) with information about the current state of the file.
  797. This routine is analogous to the ACTION_EXAMINE_OBJECT action for
  798. locks.  Because it is not always possible to provide an accurate file
  799. size (for example when buffers have not been flushed or two processes
  800. are writing to a file), the fib_Size field (see dos/dos.h) may be
  801. inaccurate.
  802.  
  803.  
  804. ACTION_ADD_NOTIFY        4097    StartNotify(NotifyRequest)
  805. ARG1:   BPTR    NotifyRequest structure
  806.  
  807. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  808. RES2:   CODE    Failure code if RES1 is DOSFALSE
  809.  
  810. This action asks a file system to notify the calling program if a
  811. particular file is altered.  A file system notifies a program either
  812. by sending a message or by signaling a task.
  813.  
  814. struct NotifyRequest {
  815.         UBYTE *nr_Name;
  816.         UBYTE *nr_FullName;             /* set by dos - don't touch */
  817.         ULONG nr_UserData;              /* for applications use */
  818.         ULONG nr_Flags;
  819.  
  820.         union {
  821.  
  822.             struct {
  823.                 struct MsgPort *nr_Port;        /* for SEND_MESSAGE */
  824.             } nr_Msg;
  825.  
  826.             struct {
  827.                 struct Task *nr_Task;           /* for SEND_SIGNAL */
  828.                 UBYTE nr_SignalNum;             /* for SEND_SIGNAL */
  829.                 UBYTE nr_pad[3];
  830.             } nr_Signal;
  831.         } nr_stuff;
  832.  
  833.         ULONG nr_Reserved[4];           /* leave 0 for now */
  834.  
  835.         /* internal use by handlers */
  836.         ULONG nr_MsgCount;              /* # of outstanding msgs */
  837.         struct MsgPort *nr_Handler;     /* handler sent to (for EndNotify) */
  838. };
  839.  
  840. To use this packet, an application needs to allocate and initialize a
  841. NotifyRequest structure (see above).  As of this writing,
  842. NotifyRequest structures are not allocated by AllocDosObject(), but
  843. this may change in the future.  The handler gets the watched file's
  844. name from the nr_FullName field.  The current file system does not
  845. currently support wild cards in this field, although there is nothing
  846. to prevent other handlers from doing so.
  847.  
  848. The string in nr_FullName must be an absolute path, including the
  849. name of the root volume (no assigns).  The absolute path is necessary
  850. because the file or its parent directories do not have to exist when
  851. the notification is set up.  This allows notification on files in
  852. directories that do not yet exist.  Notification will not occur until
  853. the directories and file are created.
  854.  
  855. An application that uses the StartNotify() DOS call does not fill in
  856. the NotifyRequest's nr_FullName field, but instead fills in the
  857. nr_Name field.  StartNotify() takes the name from the nr_Name field
  858. and uses GetDeviceProc() and NameFromLock() to expand any assigns
  859. (such as ENV:), storing the result in nr_FullName.  Any application
  860. utilizing the packet level interface instead of StartNotify() must
  861. expand their own assigns.  Handlers must not count on nr_Name being
  862. correct.
  863.  
  864. The notification type depends on which bit is set in the
  865. NotifyRequest.nr_Flags field.  If the NRF_SEND_MESSAGE bit is set, an
  866. application receives notification of changes to the file through a
  867. message (see NotifyMessage from dos/notify.h).  In this case, the
  868. nr_Port field must point to the message port that will receive the
  869. notifying message .  If the nr_Flags NRF_SEND_SIGNAL bit is set, the
  870. file system will signal a task instead of sending a message.  In this
  871. case, nr_Task points to the task and nr_SignalNum is the signal
  872. number.  Only one of these two bits should be set!
  873.  
  874. When an application wants to limit the number of NotifyMessages an
  875. handler can send per NotifyRequest, the application sets the
  876. NRF_WAIT_REPLY bit in the nr_Flags field.  This bit tells the handler
  877. not to send new NotifyMessages to a NotifyRequest's message port if
  878. the application has not returned a previous NotifyMessage.  This
  879. pertains only to a specific NotifyRequest--if other NotifyRequests
  880. exist on the same file (or directory) the handler will still send
  881. NotifyMessages to the other NotifyRequest's message ports.  The
  882. NRF_WAIT_REPLY bit only applies to message notification.
  883.  
  884. If an application needs to know if a file or directory exists at the
  885. time the application sets up notification on that file or directory,
  886. the application can set the NRF_NOTIFY_INITIAL bit in the nr_Flags
  887. field.  If the file or directory exists, the handler sends an initial
  888. message or gives an initial signal.
  889.  
  890. Handlers should only perform a notification when the actual contents
  891. of the file have changed.  This includes ACTION_WRITE,
  892. ACTION_SET_DATE, ACTION_DELETE, ACTION_RENAME_OBJECT,
  893. ACTION_FINDUPDATE, ACTION_FINDINPUT, and ACTION_FINDOUTPUT.  It may
  894. also include other actions such as ACTION_SET_COMMENT or
  895. ACTION_SET_PROTECT, but this is not required (and may not be expected
  896. by the application as there is no need to reread the data).
  897.  
  898.  
  899. ACTION_REMOVE_NOTIFY     4098    EndNotify(NotifyRequest)
  900. ARG1:   BPTR    Pointer to previously added notify request
  901.  
  902. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  903. RES2:   CODE    Failure code if RES1 is DOSFALSE
  904.  
  905. This action cancels a notification (see ACTION_ADD_NOTIFY) .  ARG1 is
  906. the NotifyRequest structure used to initiate the notification.  The
  907. handler should abandon any pending notification messages.  Note that
  908. it is possible for a file system to receive a reply from a previously
  909. sent notification message even after the notification has been
  910. terminated.  It should accept these messages silently and throw them
  911. away.
  912.  
  913.  
  914. Volume Manipulation/Information
  915.  
  916. The Volume Manipulation and Information actions are used to allow
  917. access to the underlying volume currently being manipulated by the
  918. file system.
  919.  
  920.  
  921. ACTION_CURRENT_VOLUME    7       <sendpkt only>
  922. RES1:   BPTR    Pointer to volume node of current volume
  923.  
  924. This action returns a pointer to the volume node (from the DOS device
  925. list) associated with the file system.  As the volume node may be
  926. removed from the device list when the file system mounts a different
  927. volume (such as when directed to by an ACTION_INHIBIT) there is no
  928. guarantee that this pointer will remain valid for any amount of time.
  929. This action is generally used by AmigaDOS to provide the volume line
  930. of a requester.
  931.  
  932.  
  933. ACTION_DISK_INFO         25      Info(...)
  934. ARG1:   BPTR    Pointer to an InfoData structure to fill in
  935.  
  936. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  937.  
  938.  
  939. ACTION_INFO              26      <sendpkt only>
  940. ARG1:   LOCK    Lock
  941. ARG2:   BPTR    Pointer to a InfoData Structure to fill in
  942.  
  943. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  944.  
  945. These actions are used to get information about the device and status
  946. of the file handler.  ACTION_DISK_INFO is used by the info command to
  947. report the status of the volume currently in the drive.  It fills in
  948. an InfoData structure about the volume the file system currently
  949. controls.  This structure should be longword aligned.  ACTION_INFO
  950. fills in an InfoData structure for  the volume the lock (ARG1) is on
  951. instead of the volume currently in the drive.  These actions are
  952. generally expected to return DOSTRUE.
  953.  
  954. The ACTION_DISK_INFO packet has a special meaning for console style
  955. handlers.  When presented with this packet, a console style handler
  956. should return a pointer to the window associated with the open handle.
  957.  
  958.  
  959. ACTION_RENAME_DISK      9       Relabel(...) in 2.0
  960. ARG1:   BSTR    New disk name
  961.  
  962. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  963.  
  964. This action allows an application to change the name of the current
  965. volume.  A file system implementing this function must also change
  966. the name stored in the volume node of the DOS device list.
  967.  
  968.  
  969. ACTION_FORMAT            1020    Format(fs,vol,type)
  970. ARG1:   BSTR    Name for volume (if supported)
  971. ARG2:   LONG    Type of format (file system specific)
  972.  
  973. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  974. RES2:   CODE    Failure code if RES1 is DOSFALSE
  975.  
  976. This packet tells a file system to perform any device or file system
  977. specific formatting on any newly initialized media.  Upon receiving
  978. this action, a file system can assume that the media has already been
  979. low level formatted and should proceed to write out any high level
  980. disk structure necessary to create an empty volume.
  981.  
  982.  
  983. Handler Maintenance and Control
  984.  
  985. A number of packets are defined to give an application some control
  986. over a file system:
  987.  
  988.  
  989. ACTION_DIE               5      <sendpkt only>
  990. RES1:   BOOL    DOSTRUE
  991.  
  992. As its name implies, the ACTION_DIE packet tells a handler to quit.
  993. All new handlers are expected to implement this packet.  Because of
  994. outstanding locks and the fact that the handler address is returned
  995. by the DeviceProc() routine, it is unlikely that the handler can
  996. disappear completely, but instead will have to release as many
  997. resources as possible and simply return an error on all packets sent
  998. to it.
  999.  
  1000. In the future, the system may be able to determine if there are any
  1001. outstanding DeviceProc() references to a handler, and therefore make
  1002. it is safe to shut down completely.
  1003.  
  1004.  
  1005. ACTION_FLUSH             27     <sendpkt only>
  1006. RES1:   BOOL    DOSTRUE
  1007.  
  1008. This action causes the file system to flush out all buffers to disk
  1009. before returning this packet.  If any writes are pending, they must
  1010. be processed before responding to this packet.  This packet allows an
  1011. application to make sure that the data that is supposed to be on the
  1012. disk is actually written to the disk instead of waiting in a buffer.
  1013.  
  1014.  
  1015. ACTION_MORE_CACHE        18      AddBuffers(...) in 2.0
  1016. ARG1:   LONG    Number of buffers to add
  1017.  
  1018. RES1:   BOOL    DOSTRUE (-1L)
  1019. RES2:   LONG    New total number of buffers
  1020.  
  1021. This action allows an application to change the number of internal
  1022. buffers used by the file system for caching.  Note that a positive
  1023. number increases the number of buffers while a negative number
  1024. decreases the number of buffers.  In all cases, the number of current
  1025. buffers should be returned in RES2.  This allows an application to
  1026. inquire the number of buffers by sending in a value of 0 (resulting
  1027. in no change).  Note that the OFS and FFS in 1.3 do not accept a
  1028. negative number of buffers.
  1029.  
  1030. Note that there is a bug in the ROM file system in both Release 2.04
  1031. and Release 3.0 that jumbles its return values for this packet.  The
  1032. file system erroneously returns the new number of buffers in RES1
  1033. instead of RES2 (it returns a failure code in RES2).  To work around
  1034. this bug when using this packet, test RES1 to see if it is DOSTRUE
  1035. (-1L).  If it is, look at RES2 for the number of buffers, otherwise
  1036. RES1 should contain the new total number of buffers.
  1037.  
  1038.  
  1039. ACTION_INHIBIT           31     Inhibit(...) in 2.0
  1040. ARG1:   BOOL    DOSTRUE = inhibit,      DOSFALSE = uninhibit
  1041.  
  1042. RES1:   BOOL    Success/failure (DOSTRUE/DOSFALSE)
  1043.  
  1044. This action is probably one of the most dangerous that a file system
  1045. has to handle.  When inhibited (ARG1 = DOSTRUE), the file system must
  1046. not access any underlying media and return an error code on all
  1047. attempts to access the device.  Once uninhibited (ARG1 = DOSFALSE),
  1048. the file system must assume that the medium has been changed.  The
  1049. file system must flush the buffers before the ACTION_INHIBIT ,
  1050. popping up a requester demanding that the user put back the current
  1051. disk, if necessary.  The handler may choose to reject an inhibit
  1052. request if any objects are open for writing.
  1053.  
  1054. Although it's not required, a handler should nest inhibits.  Prior to
  1055. 2.0, the system handlers did not keep a nesting count and were
  1056. subject to some obscure race conditions.  The 2.0 ROM filing system
  1057. introduced a nesting count.
  1058.  
  1059.  
  1060. ACTION_WRITE_PROTECT     1023    <sendpkt only>
  1061. ARG1:   BOOL    DOSTRUE/DOSFALSE (write protect/un-write protect)
  1062. ARG2:   LONG    32 Bit pass key
  1063.  
  1064. RES1:   BOOL    DOSTRUE/DOSFALSE
  1065.  
  1066. This is a new packet defined for the Fast File System.  This packet
  1067. allows an application to change the write protect flag of a disk (if
  1068. possible - applications cannot write to floppies that have their
  1069. write-protect tabs set).  This packet is primarily intended to allow
  1070. write-protecting non-removable media such as hard disks.  The value
  1071. in ARG1 toggles the write status.  The 32-bit passkey allows a
  1072. program to prevent other programs from unwrite-protecting a disk.  To
  1073. unlock a disk, ARG2 must match the passkey of the packet that locked
  1074. the disk, unless the disk was locked with a passkey of 0.  In this
  1075. case, no passkey is necessary to unlock the disk.
  1076.  
  1077.  
  1078. ACTION_IS_FILESYSTEM     1027    IsFileSystem(devname)
  1079.  
  1080. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  1081. RES2:   CODE    Failure code if RES1 is DOSFALSE
  1082.  
  1083. Through this function, a handler can indicates whether or not it is a
  1084. file system (whether or not it can  support separate files for
  1085. storing information).  Programs will assume a handler can create
  1086. multiple, distinct files through calls to Open() if the handler
  1087. returns this packet with a DOSTRUE value.  A handler does not need to
  1088. support directories and subdirectories in order to qualify as a file
  1089. system.  It does have to support the Examine()/ExNext() calls.
  1090.  
  1091. Note that the AmigaDOS routine IsFileSystem() will attempt to use
  1092. Lock(":",SHARED_ACCESS) if this packet returns ERROR_ACTION_NOT_KNOWN.
  1093.  
  1094.  
  1095. Handler Internal
  1096.  
  1097. There are several actions that are generally used by handlers to
  1098. allow messages returning from requested services (typically an Exec
  1099. device) to look like incoming request packets.  This allows the
  1100. handler to request an asynchronous operation but be notified of the
  1101. completion.  For example, a handler sends the serial.device a request
  1102. for a read, but instead of sending a plain IO request, it sends a DOS
  1103. packet disguised as an IO request.  The serial.device treats the
  1104. packet like a normal IO request, returning it to the handler when it
  1105. is finished. When the handler gets back its disguised DOS packet, it
  1106. knows that the read has completed.
  1107.  
  1108. ACTION_NIL               0       <internal>
  1109.  
  1110. Although not specifically an action, many returns look like this
  1111. value because the action field has not been filled in.
  1112.  
  1113. ACTION_READ_RETURN       1001    <internal>
  1114.  
  1115. Generally used to indicate the completion of an asynchronous read
  1116. request.
  1117.  
  1118. ACTION_WRITE_RETURN      1002    <internal>
  1119.  
  1120. Generally used to indicate the completion of an asynchronous write
  1121. request.
  1122.  
  1123. ACTION_TIMER             30     <internal>
  1124.  
  1125. Used to indicate the passage of a time interval.  Many handlers have
  1126. a steady stream of ACTION_TIMER packets so that they can schedule
  1127. house keeping and flush buffers when no activity has occurred for a
  1128. given time interval.
  1129.  
  1130.  
  1131. Obsolete Packets
  1132.  
  1133. There are several packet types that are documented within the system
  1134. include files that are obsolete.  A file system is not expected to
  1135. handle these packets and any program which sends these packets can
  1136. not expect them to work:
  1137.  
  1138. ACTION_DISK_CHANGE      33      <Obsolete>
  1139.  
  1140.  
  1141. ACTION_DISK_TYPE        32      <Obsolete>
  1142.  
  1143.  
  1144. ACTION_EVENT             6      <Obsolete>
  1145.  
  1146.  
  1147. ACTION_GET_BLOCK         2      <Obsolete>
  1148.  
  1149.  
  1150. ACTION_SET_MAP           4      <Obsolete>
  1151.  
  1152. Of particular note here is ACTION_DISK_CHANGE.  The DiskChange
  1153. command uses the ACTION_INHIBIT packet to accomplish its task.
  1154.  
  1155.  
  1156. Console Only Packets
  1157.  
  1158. The remaining packets are only used for console handlers and do not
  1159. need to be implemented by a file system.
  1160.  
  1161. ACTION_SCREEN_MODE       994    SetMode() in 2.0
  1162. ARG1:   LONG    Mode (zero or one)
  1163.  
  1164. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  1165. RES2:   CODE    Failure code if RES1 is DOSFALSE
  1166.  
  1167. Switch the console to and from RAW mode.  An ARG1 of one indicates
  1168. the unprocessed, raw mode while an ARG1 of zero indicates the
  1169. processed, ``cooked'' mode.
  1170.  
  1171.  
  1172. ACTION_CHANGE_SIGNAL     995    <sendpkt only>
  1173. ARG1:   LONG    The fh_Arg1 of the console file handle
  1174. ARG2:   APTR    MsgPort of the process to signal
  1175. ARG3:   LONG    Reserved, currently this must be zero
  1176.  
  1177. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  1178. RES2:   CODE    Failure code if RES1 is DOSFALSE
  1179.  
  1180. This packet redirects what process the console handler signals when
  1181. the user hits  Control-C, Control-D, Control-E, or Control-F.
  1182. Normally the process that opened the file handle receives the break
  1183. signal.
  1184.  
  1185.  
  1186. ACTION_WAIT_CHAR         20     WaitForChar()
  1187. ARG1:   ULONG   Timeout in microseconds
  1188.  
  1189. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  1190. RES2:   CODE    Failure code if RES1 is DOSFALSE
  1191.  
  1192. Performs a timed read of a character.  The WaitForChar() function
  1193. uses this packet.
  1194.  
  1195.  
  1196. ACTION_DISK_INFO         25      <sendpkt only>
  1197. ARG1:   BPTR    Pointer to an InfoData structure to fill in
  1198.  
  1199. RES1:   BOOL    Success/Failure (DOSTRUE/DOSFALSE)
  1200.  
  1201. The ACTION_DISK_INFO packet has a special meaning for console style
  1202. handlers.  When presented with this packet, a console style handler
  1203. should return a pointer to the window associated with the open handle
  1204. in the InfoData structure's id_VolumeNode field (the InfoData
  1205. structure is defined in <dos/dos.h>).  Note that some consoles can
  1206. return a NULL Window pointer (for example, an AUTO CON: or a AUX:
  1207. console).  The Amiga's standard console handler, CON:, also returns a
  1208. pointer to the console handler's IO request in the id_InUse field.
  1209. In some cases, the IO request's io_Unit field (which normally point
  1210. to a ConUnit structure) will be NULL.  See also the ACTION_DISK_INFO
  1211. packet in the ``Volume Manipulation/Information'' section.
  1212.  
  1213.  
  1214. Summary of Defined Packet Numbers
  1215.  
  1216. This is a listing of all the DOS packets defined by Commodore.
  1217. Packets 0-1999 are reserved for use by Commodore.  Unless otherwise
  1218. noted, packets 2050-2999 are reserved for use by third party
  1219. developers (see chart below).  The remaining packets are reserved for
  1220. future expansion (Note: packets 2008, 2009, 4097, and 4098 are in use
  1221. by Commodore).
  1222.  
  1223.         Decimal Hex     Action #define
  1224.  
  1225.         0       0x0000  ACTION_NIL
  1226.         1               <Reserved by Commodore>
  1227.         2       0x0002  ACTION_GET_BLOCK
  1228.         3               <Reserved by Commodore>
  1229.         4       0x0004  ACTION_SET_MAP
  1230.         5       0x0005  ACTION_DIE
  1231.         6       0x0006  ACTION_EVENT
  1232.         7       0x0007  ACTION_CURRENT_VOLUME
  1233.         8       0x0008  ACTION_LOCATE_OBJECT
  1234.         9       0x0009  ACTION_RENAME_DISK
  1235.         10-14           <Reserved by Commodore>
  1236.         15      0x000F  ACTION_FREE_LOCK
  1237.         16      0x0010  ACTION_DELETE_OBJECT
  1238.         17      0x0011  ACTION_RENAME_OBJECT
  1239.         18      0x0012  ACTION_MORE_CACHE
  1240.         19      0x0013  ACTION_COPY_DIR
  1241.         20      0x0014  ACTION_WAIT_CHAR
  1242.         21      0x0015  ACTION_SET_PROTECT
  1243.         22      0x0016  ACTION_CREATE_DIR
  1244.         23      0x0017  ACTION_EXAMINE_OBJECT
  1245.         24      0x0018  ACTION_EXAMINE_NEXT
  1246.         25      0x0019  ACTION_DISK_INFO
  1247.         26      0x001A  ACTION_INFO
  1248.         27      0x001B  ACTION_FLUSH
  1249.         28      0x001C  ACTION_SET_COMMENT
  1250.         29      0x001D  ACTION_PARENT
  1251.         30      0x001E  ACTION_TIMER
  1252.         31      0x001F  ACTION_INHIBIT
  1253.         32      0x0020  ACTION_DISK_TYPE
  1254.         33      0x0021  ACTION_DISK_CHANGE
  1255.         34      0x0022  ACTION_SET_DATE
  1256.         35-39           <Reserved by Commodore>
  1257.         40      0x0028  ACTION_SAME_LOCK
  1258.         41-81           <Reserved by Commodore>
  1259.         82      0x0052  ACTION_READ
  1260.         83-86           <Reserved by Commodore>
  1261.         87      0x0057  ACTION_WRITE
  1262.         88-993          <Reserved by Commodore>
  1263.         994     0x03E2  ACTION_SCREEN_MODE
  1264.         995     0x03E3  ACTION_CHANGE_SIGNAL
  1265.         996-1000        <Reserved by Commodore>
  1266.         1001    0x03E9  ACTION_READ_RETURN
  1267.         1002    0x03EA  ACTION_WRITE_RETURN
  1268.         1003            <Reserved by Commodore>
  1269.         1004    0x03EC  ACTION_FINDUPDATE
  1270.         1005    0x03ED  ACTION_FINDINPUT
  1271.         1006    0x03EE  ACTION_FINDOUTPUT
  1272.         1007    0x03EF  ACTION_END
  1273.         1008    0x03F0  ACTION_SEEK
  1274.         1009-1019       <Reserved by Commodore>
  1275.         1020    0x03FC  ACTION_FORMAT
  1276.         1021    0x03FD  ACTION_MAKE_LINK
  1277.         1022    0x03FE  ACTION_SET_FILE_SIZE
  1278.         1023    0x03FF  ACTION_WRITE_PROTECT
  1279.         1024    0x0400  ACTION_READ_LINK
  1280.         1025            <Reserved by Commodore>
  1281.         1026    0x0402  ACTION_FH_FROM_LOCK
  1282.         1027    0x0403  ACTION_IS_FILESYSTEM
  1283.         1028    0x0404  ACTION_CHANGE_MODE
  1284.         1029            <Reserved by Commodore>
  1285.         1030    0x0406  ACTION_COPY_DIR_FH
  1286.         1031    0x0407  ACTION_PARENT_FH
  1287.         1032            <Reserved by Commodore>
  1288.         1033    0x0409  ACTION_EXAMINE_ALL
  1289.         1034    0x040A  ACTION_EXAMINE_FH
  1290.         1035-2007       <Reserved by Commodore>
  1291.         2008    0x07D8  ACTION_LOCK_RECORD
  1292.         2009    0x07D9  ACTION_FREE_RECORD
  1293.         2010-2049       <Reserved by Commodore>
  1294.         2050-2999       <Reserved for 3rd Party Handlers>
  1295.         4097    0x1001  ACTION_ADD_NOTIFY
  1296.         4098    0x1002  ACTION_REMOVE_NOTIFY
  1297.         4099-           <Reserved by Commodore for Future Expansion>
  1298.